<template>
  <view>
    <!-- <view class="w100 h-444 absolute" style="background: linear-gradient(to bottom,#BAD8FF,#F7F7F7);"></view> -->
    <uni-status-bar></uni-status-bar>
    <view class="w100 rowscl pt-24 rowsm mb-20" @click="$tools.goNext('/pagesCopy/user/userInfo')">
      <image :src="image ? image : '/static/icon_tx.png'" class="w-118 h-118 br-59 mb-20" style="border: 2rpx solid #487EFF;"
        mode=""></image>
      <!-- <image :src="userInfo.userImage" class="w-118 h-118 br-59 mb-20" mode=""></image> -->
      <view class="fs-28 fw-b col333">
		  <!-- <view class="fs-36 col333 fw-b mb-10"> -->
        <text class="pr-50"> 姓名: {{ userInfo.name || userInfo.nickName }}</text>
		<text>{{ flag == 'student' ? '学号:' : '教工号:' }} {{ userInfo.jsNumber || userInfo.stNumber }}</text>
      </view>
      <!-- <view class="fs-28 col666">
      
      </view> -->
    </view>

    <view class="w100 relative pl-24 pr-24">
      <view class="w100 h-160 br-16 bgff rowsa rowsm mb-20" v-if="flag == 'student'">

        <view class="rowscl rowsm">
          <view class="fs-28 col333 mb-2 title">{{ userInfo.xyName }}</view>
          <view class="fs-22 col999">学院</view>
        </view>

        <view class="rowscl rowsm">
          <view class="fs-28 col333 mb-2 title">{{ userInfo.zyName }}</view>
          <view class="fs-22 col999">专业</view>
        </view>

        <view class="rowscl rowsm">
          <view class="fs-28 col333 mb-2 title">{{ userInfo.njName }}</view>
          <view class="fs-22 col999">年级</view>
        </view>
        <view class="rowscl rowsm">
          <view class="fs-28 col333 mb-2 title">{{ userInfo.bjName }}</view>
          <view class="fs-22 col999">班级</view>
        </view>
      </view>

      <!-- <view class="w100 p-all-24 br-16 bgff mb-20" style="box-shadow: 0 0 6rpx 2rpx rgba(212, 212, 212, .11);">
        <view class="fs-32 col000 fw-b mb-40">我的服务</view>
        <view class="w100 rowsa rowsm">
          <view class="rowscl rowsm" @click="$tools.goNext('/pagesCopy/user/userInfo')">
            <image src="/static/icon_ge.png" class="w-48 h-48 mb-16" mode=""></image>
            <view class="fs-24 col666">个人信息</view>
          </view>
        </view>
      </view> -->

      <view class="w100 pl-24 pt-24 pr-24 bgff br-16" style="box-shadow: 0 0 6rpx 2rpx rgba(212, 212, 212, .11);">
        <view class="fs-32 col000 fw-b">使用设置</view>
        <!-- <view class="w100 p-all-24 br-16 bgff mb-20" style="box-shadow: 0 0 6rpx 2rpx rgba(212, 212, 212, .11);">
          <view class="fs-32 col000 fw-b mb-40">我的服务</view>
          <view class="w100 rowsa rowsm">
            <view class="rowscl rowsm" @click="$tools.goNext('/pagesCopy/user/userInfo')">
              <image src="/static/icon_ge.png" class="w-48 h-48 mb-16" mode=""></image>
              <view class="fs-24 col666">个人信息</view>
            </view>
          </view>
        </view> -->

        <view class="w100 h-120 rowsb rowsm" style="border-bottom: 2rpx solid rgba(112,112,112,.1);"
          @click="$tools.goNext('/pagesCopy/user/userInfo')">
          <view class="rows rowsm">
            <image src="/static/icon_ge.png" class="w-40 h-40 mr-20" mode=""></image>
            <view class="fs-26 col666">个人信息</view>
          </view>
          <image src="/static/icon_jt.png" class="w-24 h-24" mode=""></image>
        </view>
        <view class="w100 h-120 rowsb rowsm" style="border-bottom: 2rpx solid rgba(112,112,112,.1);"
          @click="$tools.goNext('/pagesCopy/user/myGrades')" v-if="flag == 'student'">
          <view class="rows rowsm">
            <image src="/static/icon_icb-5.png" class="w-40 h-40 mr-20" mode=""></image>
            <view class="fs-26 col666">我的成绩</view>
          </view>
          <image src="/static/icon_jt.png" class="w-24 h-24" mode=""></image>
        </view>
        <!-- <view class="w100 h-120 rowsb rowsm" style="border-bottom: 2rpx solid rgba(112,112,112,.1);"
          @click="$tools.goNext('/pagesCopy/user/useInfo')">
          <view class="rows rowsm">
            <image src="/static/icon_bz.png" class="w-40 h-40 mr-20" mode=""></image>
            <view class="fs-26 col666">使用帮助</view>
          </view>
          <image src="/static/icon_jt.png" class="w-24 h-24" mode=""></image>
        </view> -->
        <view class="w100 h-120 rowsb rowsm" style="border-bottom: 2rpx solid rgba(112,112,112,.1);"
          @click="$tools.goNext('/pagesCopy/user/changePwd')">
          <view class="rows rowsm">
            <image src="/static/icon_mm.png" class="w-40 h-40 mr-20" mode=""></image>
            <view class="fs-26 col666">修改密码</view>
          </view>
          <image src="/static/icon_jt.png" class="w-24 h-24" mode=""></image>
        </view>
        <!-- <view class="w100 h-120 rowsb rowsm" style="border-bottom: 2rpx solid rgba(112,112,112,.1);">
          <view class="rows rowsm">
            <image src="/static/icon_bd.png" class="w-40 h-40 mr-20" mode=""></image>
            <view class="fs-26 col666">微信绑定</view>
          </view>
          <image src="/static/icon_jt.png" class="w-24 h-24" mode=""></image>
        </view> -->
        <!-- <view class="w100 h-120 rowsb rowsm" style="border-bottom: 2rpx solid rgba(112,112,112,.1);" @click="$tools.goNext('/pagesCopy/user/agreement?index=1')">
          <view class="rows rowsm">
            <image src="/static/icon_yh.png" class="w-40 h-40 mr-20" mode=""></image>
            <view class="fs-26 col666">用户协议</view>
          </view>
          <image src="/static/icon_jt.png" class="w-24 h-24" mode=""></image>
        </view> -->
        <!-- <view class="w100 h-120 rowsb rowsm" style="border-bottom: 2rpx solid rgba(112,112,112,.1);" @click="$tools.goNext('/pagesCopy/user/agreement?index=2')">
          <view class="rows rowsm">
            <image src="/static/icon_ys.png" class="w-40 h-40 mr-20" mode=""></image>
            <view class="fs-26 col666">隐私政策</view>
          </view>
          <image src="/static/icon_jt.png" class="w-24 h-24" mode=""></image>
        </view> -->
        <view class="w100 h-120 rowsb rowsm" style="border-bottom: 2rpx solid rgba(112,112,112,.1);" @click="outLogin()">
          <!-- $tools.goNext('/pagesCopy/user/agreement') -->
          <view class="rows rowsm">
            <image src="/static/icon_gy-1.png" class="w-40 h-40 mr-20" mode=""></image>
            <view class="fs-26 col666">退出登录</view>
          </view>
          <image src="/static/icon_jt.png" class="w-24 h-24" mode=""></image>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      flag: '',
      userInfo: {},
      image: null,
    };
  },
  onLoad() {
    this.flag = uni.getStorageSync('flag');
    // this.userInfo = this.flag == 'student' ? uni.getStorageSync('getInfo') : uni.getStorageSync('getInfo').user;
    // this.userInfo.userImage = this.userInfo.avatar ? (this.$tools.avatarUrl + this.userInfo.avatar) : '/static/icon_tx.png';
    if (this.flag == 'student') {
      this.userInfo = uni.getStorageSync('getInfo');
      this.image = this.$tools.avatarUrl + this.userInfo.userImage;
    } else {
      this.userInfo = uni.getStorageSync('getInfo').user;
      this.image = this.$tools.avatarUrl + this.userInfo.avatar;
    }
  },
  onShow() {
    // this.getUserInfo()
  },
  methods: {
    outLogin() {
      uni.showModal({
        title: '提示',
        content: '确认退出登录吗？',
        success: (res) => {
          if (res.confirm) {
            uni.removeStorageSync('flag');
            uni.removeStorageSync('getlnfo');
            uni.removeStorageSync('studentUnreport');
            sessionStorage.removeItem('token')
            // window.location.href = "http://my.lyvc.edu.cn/cas/logout?service=http://portal.lyvc.edu.cn/";
            // window.location.href = "http://192.168.10.20:8080/cas/logout";
            uni.reLaunch({
              url: '/pages/login/login'
            })
          }
        }
      })
    },
    getUserInfo() {
      this.$tools.axiosFromToken('POST', 'prouser/getById', {}, '加载中').then(res => {
        if (res.code != 200) return this.$tools.showtt(res.msg)
        let { data } = res
        data.userImage = this.$tools.avatarUrl + data.userImage
        this.userInfo = data
      })
    }
  }
}
</script>

<style lang="scss">
.title {
  text-align: center;
}
</style>
